<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>新增原辅料信息</title>
    <link rel="stylesheet" href="../../../../../public/dist/css/layui.css">
    <link rel="stylesheet" href="../../../../../css/twocss/commit.css">
    <link rel="stylesheet" href="../../../../../css/twocss/H/processing.css">
</head>

<body>
    <div class="select common">
        <form class="layui-form" action="">
            <div class="select-title" style="height:40px;line-height:40px;">
                原辅料信息
            </div>

            <div class="basis-h">
                <div class="mess-pronew">

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">原辅料名:</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input materials">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">规格:</label>
                            <div class="layui-input-inline" style="display: flex;align-items: center;">
                                <input type="text" class="layui-input  weights">(<i>kg</i>)
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">保质期:</label>
                            <div class="layui-input-inline">
                                <input type="number" class="layui-input materials">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">执行标准名称:</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input materials">
                            </div>
                        </div>
                    </div>


                </div>


                <div class="mess-pronew">

                    <div class="layui-form-item">
                        <div class="layui-inline ">
                            <label class="layui-form-label" style="width:95px;">原辅料类型:</label>
                            <div class="layui-input-inline ">
                                <select lay-filter="selec" class="selectfilters">
                                    <option value="">---请选择---</option>

                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">商品重量:</label>
                            <div class="layui-input-inline" style="display: flex;align-items: center;">
                                <input type="number" class="layui-input  weights">(<i>kg</i>)
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline ">
                            <label class="layui-form-label" style="width:95px;">商品类型:</label>
                            <div class="layui-input-inline ">
                                <select lay-filter="selec" class="selectfilters">
                                   <option value="">---请选择---</option>

                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">执行标准编号:</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input materials">
                            </div>
                        </div>
                    </div>

                </div>


                <div class="mess-pronew">

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:95px;">进货价:</label>
                            <div class="layui-input-inline" style="display: flex;align-items: center;">
                                <input type="text" class="layui-input  numsnums">(<span class="nums">袋</span>)
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </form>
        <div class="layui-btn-group" style="width: 100%;display: flex;justify-content: center;margin-top: 10px;">
            <button class="layui-btn  saves"><i class="layui-icon">&#xe674;</i>保存</button>
            <button class="layui-btn huifan"><i class="layui-icon">&#xe65c;</i>返回</button>
        </div>
    </div>
</body>


<script src="../../../../../js/common/jquery.min.js"></script>
<script src="../../../../../js/common/api.js"></script>
<script src="../../../../../public/dist/layui.js" charset="utf-8"></script>

</html>
<script>
    layui.use(['table', "layer", "form", "laydate"], function() {
        var $ = layui.jquery,
            table = layui.table,
            layer = layui.layer,
            laydate = layui.laydate,
            form = layui.form,
            projectobj = {},
            listss = null;


        //产品名称选中
        form.on('select(selec)', function(data) {

            return
        })


        //新增
        $(".saves").click(function() {
            if ($("#temis").val() == "") {
                alerts("请输选择-时间！");
                return
            }
            if ($(".selectfilters").val() == "") {
                alerts("请输选择-产品名称！");
                return
            }
            if ($(".batchs").val() == "") {
                alerts("请输入-产品批次！");
                return
            }
            if ($(".weights").val() == "") {
                alerts("请输入-生产重量！");
                return
            }
            if ($(".numsnums").val() == "") {
                alerts("请输入-生产数量！");
                return
            }
            if ($(".headpeople").val() == "") {
                alerts("请选择-负责人！");
                return
            }
            if ($(".warehouses").val() == "") {
                alerts("请选择-仓库名称！");
                return
            }

            for (var i = 0; i < $(".usetexts").children().length; i++) {
                if ($(".usetexts").children()[i].value == "") {
                    alerts("请输入-使用量！");
                    return
                }
            }


        })


        //验证重量
        $(".weights").blur(function() {
            var reg = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|^[1-9]\d*$/;
            if (!reg.test($(".weights").val())) {
                alerts("请正确输入重量!");
                $(this).val("");
                return
            }
        })


        //验证数量
        $(".numsnums").blur(function() {
            var reg = /^[1-9]\d*$/;
            if (!reg.test($(".numsnums").val())) {
                alerts("请正确输入数量!");
                $(this).val("");
                return
            }
        })



        //使用量
        function btnt() {
            var ssu = null;
            $(".btns").click(function() {
                $(this).parent().prev().children().css("display", "block");
                ssu = $(this).parent().prev().prev().text();
            })

            $(".usetexts>input").blur(function() {
                var reg = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|^[1-9]\d*$/;
                if (!reg.test($(this).val())) {
                    alerts("请正确输入使用量!");
                    $(this).val("");
                    return
                }

                if (Number(ssu) < Number($(this).val())) {
                    alerts("输入量超库存!")
                    $(this).val("");
                }
            })

        }


        //返回
        $(".huifan").click(function() {
            window.location.href = "../../Jbasis/material.html";
        })

    })
</script>